package com.soft.security.action;

import javax.annotation.Resource;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.soft.core.action.BaseAction;
import com.soft.core.dao.GenericDao;
import com.soft.security.dao.JobDao;
import com.soft.security.domain.Job;

@Controller("jobAction")
@Scope("prototype")
public class JobAction extends BaseAction<Job> {
	
	private JobDao jobDao;

	@Resource
	public void setJobDao(JobDao jobDao) {
		this.jobDao = jobDao;
	}

	@Override
	public GenericDao<Job> getDao() {
		return jobDao;
	}
	
	@Override
	public void beforFind(DetachedCriteria criteria) {
		if (null != model.getJobName() && !"".equals(model.getJobName().trim())) {
			criteria.add(Restrictions.like("jobName", model.getJobName(), MatchMode.ANYWHERE));
		}
	}

}
